/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.ncsu.util;

import java.util.Enumeration;

/**
 *
 * @author me
 */
public class MyStringTokenizer implements Enumeration {
    private String theString;
    private String delim;
    private int index = 0;
    private int from;

    public MyStringTokenizer(String s, String d) {
        theString = s;
        delim = d;
    }

    public MyStringTokenizer(String s) {
        this(s, ",");
    }

    public String nextToken() {
        if (index >= theString.length()) {
            return null;
        }
        from = index;
        index = theString.indexOf(delim, index);
        return theString.substring(from, index++);
    }

    public boolean hasMoreElements() {
        return index < theString.length();
    }

    public Object nextElement() {
        return nextToken();
    }

}
